//
//  KLMCard.swift
//  KLM_GN
//
//  Created by Nic on 2025/2/26.
//

import UIKit

enum CardType {
    case none  //默认
    case roomList  //房间列表
    case aiMode  //AI模式
    case sceneMode  //情景模式
}

enum CardSubType {
    case title  //纯文字
    case add  //添加/创建
    case edit  //有编辑图标
    case delete  //待删除
    case time  //时间
    case customTime  //自定义时间
    case longPress  //长按自定义时间
}

struct KLMCard {
    
    var type: CardType = .none
    var subType: CardSubType = .title
    var title: String = ""
    var titleIcon: String? = "add"
    var isDelete: Bool = false
    var deleteIcon : String? = "delete"
    var editable: Bool = false
    var editIcon : String? = "edit"
    var subTitle : String?
    var tip : String?
    var select: Bool = false
    var isOn: Bool = false
    var onOffImg: String? = "switch_off"
    
    // 便利构造器
    init(type: CardType = .none, subType: CardSubType = .title, title: String = "", titleIcon: String? = nil, isDelete: Bool = false, deleteIcon: String? = nil, editable: Bool = false, editIcon: String? = nil, subTitle: String? = nil, tip: String? = nil, select: Bool = false, isOn: Bool = false, onOffImg: String? = nil) {
        self.type = type
        self.subType = subType
        self.title = title
        self.titleIcon = titleIcon
        self.isDelete = isDelete
        self.deleteIcon = deleteIcon
        self.editable = editable
        self.editIcon = editIcon
        self.subTitle = subTitle
        self.tip = tip
        self.select = select
        self.isOn = isOn
        self.onOffImg = onOffImg
    }
    
    static func roomListCards(titles: [String]?) -> [KLMCard] {
        return [
            KLMCard(type: .roomList, title: "主卧"),
            KLMCard(type: .roomList, title: "卧室"),
            KLMCard(type: .roomList, title: "书房"),
        ]
    }
    
//    static func aiModeCards() -> [KLMCard] {
//        return [
//            KLMCard(type: .aiMode, title: "工作模式", subTitle: "点击可自定义参数"),
//            KLMCard(type: .aiMode, title: "休息模式", subTitle: "点击可自定义参数"),
//            KLMCard(type: .aiMode, title: "阅屏模式", subTitle: "点击可自定义参数"),
//            KLMCard(type: .aiMode, title: "节能模式", subTitle: "点击可自定义参数")
//        ]
//    }
    static func aiSceneModeCards(rkScenes: [KLMRKScene]) -> [KLMCard] {
        return rkScenes.map {
            KLMCard(type: .aiMode, title: $0.rkSceneName ?? "工作模式", subTitle: "点击可自定义参数", isOn: $0.sceneButton == 1)
        }
    }
    
    static func situationModeCards(rkScenes: [KLMRKScene]) -> [KLMCard] {
        return rkScenes.map {
            // sceneButton：0未选择，1选中
            KLMCard(type: .sceneMode, title: $0.rkSceneName ?? "模式", editable: true, select: $0.sceneButton == 1)
        }
    }
//    static func sceneModeCards() -> [KLMCard] {
//        return [
//            KLMCard(type: .sceneMode, title: "读写模式", editable: true),
//            KLMCard(type: .sceneMode, title: "阅屏模式", editable: true),
//            KLMCard(type: .sceneMode, title: "专注模式", editable: true),
//            KLMCard(type: .sceneMode, title: "小夜灯模式", editable: true),
//            KLMCard(type: .sceneMode, subType: .longPress, title: "助眠模式", editable: true, subTitle: "30分钟后熄灭", tip: "长按可自定义时间"),
//            KLMCard(type: .sceneMode, subType: .add, title: "创建模式")
//        ]
//    }
    static func aiWorkModeCards() -> [KLMCard] {
        return [
            KLMCard(type: .aiMode, title: "10", subTitle: "分钟"),
            KLMCard(type: .aiMode, title: "15", subTitle: "分钟"),
            KLMCard(type: .aiMode, title: "30", subTitle: "分钟"),
            KLMCard(type: .aiMode, title: "45", subTitle: "分钟"),
            KLMCard(type: .aiMode, subType: .customTime, title: "", subTitle: "分钟", tip: "自定义时间")
        ]
    }
    static func aiRestModeCards() -> [KLMCard] {
        return [
            KLMCard(type: .aiMode, title: "45", subTitle: "分钟"),
            KLMCard(type: .aiMode, subType: .customTime, title: "", subTitle: "分钟", tip: "自定义时间")
        ]
    }
}
